<!DOCTYPE html>
<html>
    <title>
        <title>46jQuery替换节点的相关方法</title>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <script src="http://code.jquery.com/jquery-1.12.4.js" 
            integrity="sha256-Qw82+bXyGq6MydymqBxNPYTaUXXq7c8v3CwiYwLLNXU="
            crossorigin="anonymous"></script>
        <script>
            $(function (param) { 
                /*
                替换
                replaceWith()
                replaceAll()
                替换所有匹配的元素为指定的元素
                */ 
                $("button").click(function (param) { 
                    //1.新建一个元素
                    var $h6=$("<h6>我是标题6</h6>");
                    //2.替换元素
                    $("h1").replaceWith($h6);
                    $h6.replaceAll("h1");
                 });
            });
        </script>
    </head>
    <body>
        <button>替换节点</button>
        <h1>我是标题</h1>
        <p>我是段落</p>
    </body>
</html>